<?php
namespace App\Http\Controllers\ApiApp;

use App\DBs\VideoDB;
use Illuminate\Http\Request;

class VideoController extends BaseController
{
    //特效

    protected $db;

    public function __construct()
    {
        parent::__construct();
        $this->db = new VideoDB();
    }

    //果干一个
    public function getOne(Request $request)
    {
        $wx = $request->post('wx','');
        $id = $request->post('id',0);
        $oper = $request->post('oper',0); //1上拉，2下拉，
        if (!in_array($oper,[1,2])) {
            return $this->toAppJson(-2);
        }
        $resDb = $this->db->getOneByOper($wx,$id,$oper,1);
        if ($resDb['code']!=0) {
            return $this->toAppJson(-3);
        }
        $items = $resDb['data'];
        return $this->toAppJson(0,$items);
    }

    //农产品一个
    public function getSideOne(Request $request)
    {
        $wx = $request->post('wx','');
        $id = $request->post('id',0);
        $oper = $request->post('oper',0); //1上拉，2下拉，
        if (!in_array($oper,[1,2])) {
            return $this->toAppJson(-2);
        }
        $resDb = $this->db->getOneByOper($wx,$id,$oper,2);
        if ($resDb['code']!=0) {
            return $this->toAppJson(-3);
        }
        $items = $resDb['data'];
        return $this->toAppJson(0,$items);
    }
}